from abc import ABC, abstractmethod
from typing import Dict, Any
from models.m import User

class BaseProvider(ABC):
    """基础提供者抽象类"""
    
    def __init__(self, config: Dict[str, Any]):
        self.config = config
    
    @abstractmethod
    async def get_authorization_url(self) -> str:
        """获取授权URL"""
        pass
    
    @abstractmethod
    async def exchange_code_for_token(self, code: str) -> Dict[str, Any]:
        """用授权码换取访问令牌"""
        pass
    
    @abstractmethod
    async def get_user_info(self, access_token: str) -> Dict[str, Any]:
        """获取用户信息"""
        pass
    
    @abstractmethod
    async def save_user_info(self, user_info: Dict[str, Any], token_info: Dict[str, Any]) -> User:
        """保存用户信息到数据库"""
        pass